<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/** Clients models **/
class Clients extends CI_Model {
	private $client = 'potential_client';
	
	
	function getAllRecords($category='',$limit=10,$week=''){
		$this->db->select("*");
		$Q=$this->db->get($this->client);
		return $Q->result_array();
	}
	
	function getDataSingleRecord($id){
		$this->db->where('client_id',$id);
		$Q=$this->db->get($this->client);
		return $Q->row_array();
	}
	
	function saveClient(){
		$value =  array( 'client_name'  		=>  $this->input->post('name'),
						 'client_address'		=>	$this->input->post('address'),
						 'client_date'  		=>  date('Y-m-d H:i:s'),
						 'client_contact'		=>	$this->input->post('contact'),
						 'client_business' 		=>	$this->input->post('business'),
						 'client_shareholders'	=>	$this->input->post('shareholders'),
						 'client_directors'		=>	$this->input->post('directors'),
						 'client_commisioners'	=>	$this->input->post('commisioners'),
						 'client_service'		=>	$this->input->post('service'),
						 'client_year'			=>	$this->input->post('year'),
						 'client_website'		=>	$this->input->post('website'),
						 'client_information'	=>	$this->input->post('information'),
						 'client_from'			=>	$this->input->post('from'),
						 'EmployeeID'			=>	$this->session->userdata('user_login'));
		$this->db->insert($this->client,$value);				 
	}
	
	function updateClient(){
		$value =  array( 'client_name'  		=>  $this->input->post('name'),
						 'client_address'		=>	$this->input->post('address'),
						 'client_date'  		=>  date('Y-m-d H:i:s'),
						 'client_contact'		=>	$this->input->post('contact'),
						 'client_business' 		=>	$this->input->post('business'),
						 'client_shareholders'	=>	$this->input->post('shareholders'),
						 'client_directors'		=>	$this->input->post('directors'),
						 'client_commisioners'	=>	$this->input->post('commisioners'),
						 'client_service'		=>	$this->input->post('service'),
						 'client_year'			=>	$this->input->post('year'),
						 'client_website'		=>	$this->input->post('website'),
						 'client_information'	=>	$this->input->post('information'),
						 'client_from'			=>	$this->input->post('from'),
						 'EmployeeID'			=>	$this->session->userdata('user_login'));
		$this->db->where('client_id',$this->input->post('id'));
		$this->db->update($this->client,$value);				 
	}
	
	function removeClient($id){
		$this->db->where('client_id',$id);				 
		$this->db->delete($this->client);				 
	}
	
}